package com.dzsw.netty.basic.future;

import java.util.UUID;
import java.util.concurrent.Future;

public class EventLoopTest {

    public static void main(String[] args) throws Exception {
        EventLoop eventLoop = new EventLoop();

        eventLoop.submit(() -> {
            System.out.println(
                    String.format("Thread => Name: %s, Id: %s",
                            Thread.currentThread().getName(),
                            Thread.currentThread().getId()));
        });

        Future f = eventLoop.submit(() -> {
            Thread.sleep(5 * 1000);
            return UUID.randomUUID();
        });

        for (; ; ) {
            if (f.isDone()) {
                System.out.println(f.get());
                break;
            } else {
                System.out.println("Thread is running...");
                Thread.sleep(1000);
            }
        }
        Thread.sleep(2 * 1000);
        eventLoop.stop();
    }
}
